<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="div1">
    aaa
    <div id="div2">
        bbb
        <div id="div3">
            ccc

        </div>
    </div>
</div>
<script>
    var div1 = document.getElementById('div1');
    var div2 = document.getElementById('div2');
    var div3 = document.getElementById('div3');

//    div1.onclick = function(e){
//        alert("aa")
//    }
//    div2.onclick = function(e){
//        alert("bb")
//    }
//    div3.onclick = function(e){
//        e.cancelBubble = true;
//       alert('aaa');
//    }
    div2.attachEvent('onclick',function(e){
       alert('bb')
    })
    div3.attachEvent('onclick',function(e){
        e.cancelBubble = true;
       alert('aaa');
        alert(console.log(e.cancelBubble));
    })
</script>
</body>
</html>